<template>
  <!-- 详情 -->
  <div>
    <el-main>
      <div style="font-size: 16px;padding-bottom: 10px;border-bottom: 1px solid #eee;margin-bottom: 15px;">
        <span style="display: inline-block;padding-left: 10px;border-left: 4px solid #1890ff;">基本信息</span>
      </div>

      <div style="display: flex;margin-top: 20px;">
        <div :disabled="true" style="margin-top: 7px;width: 100px;text-align: right;"><span style="color: red;">*</span>采购员编号：</div>
        <div style="width: 400px">
          <el-input placeholder="长度＜10,必填项" disabled v-model="info.code">
          </el-input>
        </div>
      </div>
      <div style="display: flex;margin-top:20px;">
        <div style="margin-top: 7px;width: 100px;text-align: right;"><span style="color: red;">*</span>采购员名称：</div>
        <div style="width: 400px">
          <el-input placeholder="长度＜10,必填项" disabled v-model="info.name">
          </el-input>
        </div>
      </div>

      <div style="display: flex;margin-top: 20px;">
        <div style="margin-top: 7px;width: 100px;text-align: right;"><span style="color: red;">*</span>手机号：</div>
        <div style="width: 400px">
          <el-input disabled placeholder="长度＜13,必填项" v-model="info.phone">
          </el-input>
        </div>
      </div>

      <el-button style="margin-top: 20px;margin-left: 40px;" @click="funcback">返回</el-button>

  </el-main>
  </div>
</template>

<script>
  import {handleActivePath} from '@/utils/routes'
  import {getPurchaserInfo} from '@/api/purchase/buyerapi.js'

  import {
    mapActions
  } from 'vuex'

  import { getbuyerAll, editbuyer } from '@/api/purchase/buyerapi.js'
  import { editsupplier } from "@/api/purchase/supplierapi";
  export default {
    data() {
      return {
        info: {  }, //储存信息
        options:[],
      }
    },
    methods: {
      ...mapActions({
        delVisitedRoute: 'tabs/delVisitedRoute',
      }),
      async fetchPurchaserInfo(data){
        let res = await getPurchaserInfo(data)
        this.info = res.data;
      },
      funcback() {
        this.$confirm('确定返回列表页面?', '确定', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
          .then(async () => {
            const detailPath = await handleActivePath(this.$route, true)
            await this.$router.push('/purchase/initialvalue/buyer')
            await this.delVisitedRoute(detailPath)
          })
          .catch(() => {})
      },
      async addfunc() {
        if (this.info.name == "" || this.info.code == "" || this.info.phone.length != 11 || this.info.name == "" || this.info.name
          .length > 10) {
          this.$message.error('请正确填写信息');
          return
        }
        // {"id":3 ,"name":"赵子龙", "code": "004", "phone": "1239999", "remarks": "王牌采购", "wsId": 1}
        let res = await editbuyer(this.info);
        if (res.status == 200) {
          this.$router.push("/purchase/initialvalue/buyer")
          this.$message('修改成功');
        } else {
          this.$message.error('修改失败');
        }
      }
    },
    async created() {
      let id = this.$route.params.id
      let data = { "id": id }
      await this.fetchPurchaserInfo(data);
    }
  }
</script>

<style>
</style>
